//
//  WithDrawlRecordViewModel.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/6.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "WithDrawlRecordViewModel.h"
#import "WithDrawlRecordTableViewCell.h"

@interface WithDrawlRecordViewModel ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *selfTableView;
}

@end

@implementation WithDrawlRecordViewModel

- (instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView
{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        
        tableView.height -= kHeightProportion_In_iPhoneTriploid(44);
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        [superView addSubview:tableView];
        selfTableView = tableView;
    }
    return self;
}

#pragma mark - tableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kHeightProportion_In_iPhoneTriploid(139);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WithDrawlRecordTableViewCell *cell = [WithDrawlRecordTableViewCell cellWithTableView:tableView];
    if (self.withDrawRecordType == WithDrawRecordType_All) {
        if (indexPath.row == 0) {
            cell.withDrawRecordType = WithDrawRecordType_ToAudit;
        } else if (indexPath.row == 1) {
            cell.withDrawRecordType = WithDrawRecordType_HaveWithdrawal;
        }  else if (indexPath.row == 2) {
            cell.withDrawRecordType = WithDrawRecordType_ForWithdrawal;
        } else  {
            cell.withDrawRecordType = WithDrawRecordType_AuditFailure;
        }
    } else {
        cell.withDrawRecordType = self.withDrawRecordType;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.BlockWithDrawlDetail) {
        self.BlockWithDrawlDetail(indexPath, @"");
    }
}

@end
